package cn.gz.demo.ui.tab_fragment;


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Nullable;

import cn.gz.demo.R;
import cn.gz.demo.adapter.HomeAdapter;
import cn.gz.demo.databinding.Tab1Binding;

/**
 * Created by Lyz on 2017/3/8.
 */
public class HomeFrament extends Fragment {
    private Tab1Binding binding;
    private List<String> list = new ArrayList<>();
    private HomeAdapter adapter;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.tab_fragment_1, container, false);
        return binding.getRoot();
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);

        binding.recylerview.setLayoutManager(new LinearLayoutManager(getContext()));
        adapter = new HomeAdapter(getActivity(), list);
        binding.recylerview.setAdapter(adapter);

        for (int i = 0; i < 10; i++) {
            list.add("列表" + (i + 1));
        }
        adapter.notifyDataSetChanged();
    }
}
